package com.hsy.linemoney.modules.my.cash_and_report;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.deparse.dpframe.ui.android.widget.adapter.DPBaseAdapter;
import com.hsy.linemoney.R;
import com.hsy.linemoney.apiservice.AccountService;

import java.util.List;

/**
 * Created by MartinKent on 2016/10/25.
 */

public class CashAndReportAdapter extends DPBaseAdapter<AccountService.CashflowResult.Transactions> {

    public CashAndReportAdapter(Context context) {
        super(context);
    }

    public CashAndReportAdapter(Context context, List<AccountService.CashflowResult.Transactions> data) {
        super(context, data);
    }

    @Override
    public CommonBaseViewHolder<AccountService.CashflowResult.Transactions> getHolder(int i) {
        return new CashAndReportAdapter.ViewHolder();
    }

    private class ViewHolder extends CommonBaseViewHolder<AccountService.CashflowResult.Transactions> {
        private TextView type;
        private TextView time;
        private TextView payout;
        private TextView payin;
        private TextView zhye;
        private TextView jyxq;

        @Override
        public View create(int i) {
            View convertView = inflater.inflate(R.layout.cash_and_report_list_item, null);

            type = (TextView) convertView.findViewById(R.id.type);
            time = (TextView) convertView.findViewById(R.id.time);
            payout = (TextView) convertView.findViewById(R.id.payout);
            payin = (TextView) convertView.findViewById(R.id.payin);
            zhye = (TextView) convertView.findViewById(R.id.zhye);
            jyxq = (TextView) convertView.findViewById(R.id.jyxq);

            return convertView;
        }

        @Override
        public void update(int i, AccountService.CashflowResult.Transactions bean) {
            type.setText(bean.getServiceTypeCd());
            time.setText(bean.getTransactionDate());
            payout.setText(bean.getDebit());
            payin.setText("");
            jyxq.setText(bean.getDescription());
            zhye.setText(bean.getBalance());
        }
    }
}